package infostroy.bookagolf.components.controls;

import infostroy.bookagolf.UI.GolfCommonButtonUI;

import javax.swing.*;
import java.awt.*;

/**
 * Created by valer_000 on 2/8/14.
 */
public class GolfRoundButton extends JButton {

    private Dimension dimension;

    /**
     * Constructs rounded button with specified text and dimension.
     * @param text button label.
     * @param background  background color.
     * @param foreground label color.
     * @param selectedBorder  border color when button has focus.
     * @param dimension  maximum size of button.
     */
    public GolfRoundButton(String text, Color background, Color foreground
            , Color selectedBorder, Dimension dimension) {
        super(text);
        this.dimension = dimension;
        this.setBorderPainted(false);
        this.setPreferredSize(dimension);
        this.setMaximumSize(dimension);
        this.setContentAreaFilled(false);
        this.setUI(new GolfCommonButtonUI(background, foreground, selectedBorder));
    }

    /**
     * Constructs rounded button with specified icon and background color.
     * It doesn't render focus state. Border also ignored.
     * @param icon  button icon.
     * @param background  background color.
     * @param dimension  maximum dimension of button.
     */
    public GolfRoundButton(Icon icon, Color background, Dimension dimension) {
        super(icon);
        this.dimension = dimension;
        this.setPreferredSize(dimension);
        this.setMaximumSize(dimension);
        this.setUI(new GolfCommonButtonUI(background, null, null));
    }

    @Override
    public Dimension getPreferredSize() {
        return dimension;
    }

    @Override
    public Dimension getMaximumSize() {
        return dimension;
    }
}
